{% extends "admin_base.html" %}
{% block pageContent %}
    <form enctype="multipart/form-data" method="POST">
    <table>
        {{ form.as_table }}
        {% for inline_formset in inline_formsets %}
        <tr>
            <td></td>
            <td>
            <div class="inline_formset_label">{{ inline_formset.label }}</div>
            {{ inline_formset.form.management_form }}
            <table class="inline_formset">
                <tr class="inline_formset_header">
            {% for header in inline_formset.headers %}
                <th class="inline_formset_header">{{ header }}</th>
            {% endfor %}
                </tr>
            {% for inline_form in inline_formset.form.forms %}
                {% if not inline_form.is_valid %}
                <tr>
                    {% for field in inline_form %}
                        <td class="inline_error_message">{{ field.errors }}</td>
                    {% endfor %}
                </tr>
                {% endif %}
                <tr>
                {% for field in inline_form %}
                    {% if field.errors %}
                        <td class="inline_error_field">{{ field }}</td>
                    {% else %}
                        <td>{{ field }}</td>
                    {% endif %}
                {% endfor %}
                    </tr>
            {% endfor %}
                </tr>
            </table>
            </td>
        </tr>
        {% endfor %}
    <tr>
        <th>&nbsp;</th>
        <td>
            {% if form.instance.id %}
            <input id="submitButton" type="submit" value="Update" />
            {% else %}
            <input id="submitButton" type="submit" value="Create" />
            {% endif %}
            <input id="cancelButton" type="button" value="Cancel" onclick="history.back();" />
        </td>
    </tr>
    </table>
    </form>
    <script type="text/javascript">
    {% if tinyMCE %}
        $(document).ready(function() {
            $('#id_message, #id_supporting_information').tinymce({
                mode: 'exact',
                theme: 'advanced'
            });
        });
    {% endif %}
    {% block javascript %}
    {% endblock %}
    </script>
{% endblock %}